﻿using Autofac;
using System.Reflection;

namespace GGGK.Film.Api.Comm
{
    public class CustomAutofacModule:Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            // 获取仓储和服务的程序集
            List<Type> types = new List<Type>();
            var svrNames = new string[] { "GGGK.Film.Repository", "GGGK.Film.Service" };
            foreach (var item in svrNames)
            {
                Assembly assembly = Assembly.Load(item);

                types.AddRange(assembly.GetTypes());
            }

            // 批量注册
            builder.RegisterTypes(types.ToArray())
                .AsImplementedInterfaces().InstancePerLifetimeScope().PropertiesAutowired();
        }

    }
}
